package com.teamwings.modules.design.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.teamwings.ctrls.Field;
import com.teamwings.ctrls.entity.DatabaseTable;
import com.teamwings.ctrls.entity.DatabaseTableWithColumns;
import com.teamwings.modules.code.entity.FormTableCode;
import com.teamwings.modules.design.vo.FormTableVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DesignMapper {

    @InterceptorIgnore(tenantLine = "true")
    Integer createTable(@Param("tableName") String tableName, @Param("statementList") List<String> statementList);

    Boolean hasTable(@Param("tableName") String tableName);

    Boolean hasData(@Param("tableName") String tableName);

    void dropColumn(@Param("tableName") String tableName, @Param("column") String column);

    Integer addColumn(@Param("tableName") String tableName, @Param("statement") String statement);

    void columnRename(
            @Param("tableName") String tableName,
            @Param("originColumn") String originColumn,
            @Param("column") String column
    );

    @InterceptorIgnore(tenantLine = "true")
    void editColumnType(@Param("tableName") String tableName, @Param("statement") String statement);

    Integer cloneTable(@Param("originTableName") String originTableName, @Param("tableName") String tableName);

    List<FormTableVo> getLatestListByFormIds(@Param("headIds") List<String> headIds);

    List<DatabaseTable> allTable();

    List<DatabaseTableWithColumns> allTableWithColumns();

    DatabaseTableWithColumns getTableWithColumns(@Param("tableName") String tableName);
}
